//传入 名字、花费金钱数、建造时间、建筑名字
//即可为玩家添加一个建造动作


params["_name", "_money", "_time", "_type"];

private _actionName = format["<t color=""#00ff00"">%1</t><t color=""#d50e0e"">[-%2]</t><t color=""#ffff00"">[%3s]</t>", _name, _money, _time];
private _checkStr = format["player getVariable ['as_money',0] >= %1", _money];


player addAction [_actionName, 
{
	params ["_target", "_caller", "_actionId", "_arguments"];
	if(!as_cb_ing) then
	{
		_arguments spawn
		{
			params["_money", "_time", "_type"];
			//标记正在建造
			as_cb_ing = true;
			private _as_cb_count = 0;
			TitleText ["按X键取消建造", "Plain Down"];
			
			//计算动作次数
			private _count = ceil(_time / 6.0);
			for ("_i") from 1 to _count do {
				[player,"AmovPknlMstpSnonWnonDnon"]remoteExec["playMove",0];
				[player,"AinvPknlMstpSnonWnonDr_medic5"]remoteExec["playMove",0];
			};
			
			//直到取消
			while {as_cb_ing}do
			{
				uiSleep 1.0;
				_as_cb_count = _as_cb_count + 1;
				
				if((!alive player) || {player getVariable ["FAR_isUnconscious",1] == 1}) exitWith
				{
					as_cb_ing = false;
				};
				
				if(_as_cb_count >= _time) then
				{
					[_type, getPosASL player , getDir player]remoteExec["fn_createVehSimple",2];
					private _player_money = player getVariable["as_money", 0];
					player setVariable["as_money",  _player_money - _money, true];
					as_cb_ing = false;
				};
			};
			
			//
			[player,"AmovPknlMstpSnonWnonDnon"]remoteExec["switchMove",0];
		};
	};
}, [_money, _time, _type], -1000 - _money, false, true, "", _checkStr];
